home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 4 / The Arsenal Files 4 (Arsenal Computer).ISO / casm / au116-as.exe / UTIL / CLEANPTH.CPP < prev    next >
C/C++ Source or Header  |  1994-06-06  |  937b  |  48 lines

  1. #include "..\au.hpp"
  2. /**************************************************************************/
  3. int clean_paths(AU *au, LISTPTR *paths_list)
  4. {
  5.     int   largest;
  6.     int   len;
  7.     LIST *save;
  8.     LIST *el;
  9.  
  10.     /* kill all the files and directories behind */
  11.     for (el = paths_list->head; el != NULL; el = el->next)
  12.     {
  13.         cd(au, el->data);
  14.         system("echo Y | del *.* >NUL");
  15.  
  16.         /* Null out destination directory */
  17.         if (el->next == NULL)
  18.             el->data[0] = '\0';
  19.     }
  20.     cd(au, au->source_directory);
  21.  
  22.     /* Remove the directories, largest first */
  23.     for(EVER)
  24.     {
  25.         save = NULL;
  26.         largest = 0;
  27.         for (el = paths_list->head; el != NULL; el = el->next)
  28.         {
  29.             if (el->data[0] != '\0')
  30.             {
  31.                 len = strlen(el->data);
  32.                 if (len > largest)
  33.                 {
  34.                     largest = len;
  35.                     save = el;
  36.                 }
  37.             }
  38.         }
  39.         if (save == NULL)
  40.             break;
  41.  
  42.         rmdir(save->data);
  43.         save->data[0] = '\0';
  44.     }
  45.     paths_list->destroy();
  46.     return 0;
  47. }
  48.